package com.example.usercenter.config.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;

/**
 * Created by ZXN on 2018/9/29.
 */
@Configuration
@ConfigurationProperties(
        prefix = "app",
        ignoreUnknownFields = false
)
public class AppProperties {
    private final Metrics metrics = new Metrics();
    private final CorsConfiguration cors = new CorsConfiguration();

    public Metrics getMetrics() {
        return metrics;
    }

    public CorsConfiguration getCors() {
        return cors;
    }

    public static class Metrics{
        private final Jmx jmx = new Jmx();
        private final Logs logs = new Logs();

        public Jmx getJmx() {
            return this.jmx;
        }

        public Logs getLogs() {
            return this.logs;
        }

        public static class Logs {
            private boolean enabled = false;
            private long reportFrequency = 60L;

            public Logs() {
            }

            public boolean isEnabled() {
                return this.enabled;
            }

            public void setEnabled(boolean enabled) {
                this.enabled = enabled;
            }

            public long getReportFrequency() {
                return this.reportFrequency;
            }

            public void setReportFrequency(long reportFrequency) {
                this.reportFrequency = reportFrequency;
            }
        }

        public static class Jmx {
            private boolean enabled = true;

            public Jmx() {
            }

            public boolean isEnabled() {
                return this.enabled;
            }

            public void setEnabled(boolean enabled) {
                this.enabled = enabled;
            }
        }
    }
}
